<template>
  <div class="right-chart-1">
    <div class="mask" v-if="showModal" @click="showModal=false"></div>
    <div class="pop" v-if="showModal">
        <img src="@/assets/img/close.png" @click="showModal=false" />
        <!-- <button @click="showModal=false" class="btn">点击出现弹框</button> -->
        <div class="showTxt" v-if="showFlag=='0'">异常查看 
          <p><a   @click="abtn">332</a></p>
          <!-- :href="`${content}`" -->
          
          </div>
        <div class="showTxt" v-else-if="showFlag=='1'">产能分析</div>
        <div class="showTxt" v-else-if="showFlag=='2'">生产操作手册</div>
        <div class="showTxt" v-else>操作日志</div>
    </div>   
    <div class="btn-box">
      <a href="javascript:;" v-for="(item,index) in btnList" :key="index" @click="show(index)" :class="{selected:index == current}" class="btn">{{item}}</a>
    </div>
  </div>
</template>

<script>
import {recording} from '@/network/home'
export default {
  name: "RightChart1",
  props:{
    stationId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      btnList:['异常查看','产能分析','生产操作手册','操作日志'],
      current:5,
      showModal: false,
      showFlag:'',
      content:''

    }
  },
  mounted() {
    // this.getRecording();
  },
  watch:{
    showModal(newVal){
      if(!newVal) this.current = 5;
    }
  },
  methods: {
    abtn(){
      window.open ('http://news.sohu.com/','_blank','height=600,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no') 
    },
    show(index){
      recording({stationId:this.stationId,type:index+1}).then(res => {
        console.log('res',res.data);
        this.content = res.data.data;
      })
      this.current = index;
      this.showFlag = index;
      this.showModal = true;
    }
  },
  
}
</script>

<style lang="less">
.right-chart-1 {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  display: flex;
  flex-direction: column;
  flex-grow: 0;
}
.selected{
  background-color: green !important;
}
.mask {
  background-color: #000;
  opacity: 0.3;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.pop {
  background-color: #fff;
 
  position: fixed;
  top: 100px;
  left: 300px;
  width: calc(100% - 600px);
  height:calc(100% - 200px);
  z-index: 2;
  border-radius: 2px;
  .showTxt{
    color: #333;
    font-size: 24px;
    font-weight: 700;
  }
  img{
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    cursor: pointer;
  }
}

.btn-box{
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  padding: 10px;
  box-sizing: border-box;
  .btn {
    margin-bottom: 16px;
    background-color: #3BC5EC;
    border-radius: 4px;
    width: 36%;
    height: 40px;
    line-height: 40px;
    color: #fff;
    text-decoration: none;
  }
}

</style>